package com.FundamentalDemos.Operator;

public class 复合赋值运算符 {
    public static void main(String[] args) {
        /*
            +=  a+=b    a=(a的类型)(a+b)
            -=  a-=b    a=(a的类型)(a-b)
            *=  a*=b    a=(a的类型)(a*b)
            /=  a/=b    a=(a的类型)(a/b)
            %=  a%=b    a=(a的类型)(a%b)

            注意:复合赋值运算符隐含了强制的类型转换!

        */
        double a = 9.5;
        double b = 520;
        a += b;//a = (double)(a+b)
        System.out.println(a);

        double i = 600;
        double j = 520;
        i -= j;
        System.out.println(i);

        a = 2;
        b = 3;
        a *= a + b;//a = (double)(a*(a+b))
        System.out.println(a);

        a = 2;
        b = 3;
        a = a * a + b;
        System.out.println(a);

        byte x = 10;
        byte y = 30;
        int z = x + y;//byte + byte -> int
        x += y;//等价于x = (byte)(x+y)


    }
}
